﻿namespace DataCollection
{
    public class Log
    {
        #region 属性
        /// <summary>日志工具
        /// 
        /// </summary>
        private NLog.Logger logger;

        /// <summary>Log实例
        /// 
        /// </summary>
        private static Log log = new Log();

        public static Log Default { get; private set; }

        #endregion

        #region 自定义方法

        public static void Debug(string msg, params object[] args)
        {
            log.LDebug(msg, args);
        }

        public static void Info(string msg, params object[] args)
        {
            log.LInfo(msg, args);
        }

        public static void Error(string msg, params object[] args)
        {
            log.LError(msg, args);
        }

        private Log(NLog.Logger logger)
        {
            this.logger = logger;
        }

        public Log() : this(NLog.LogManager.GetLogger("log"))
        {
        }

        static Log()
        {
            Default = new Log(NLog.LogManager.GetCurrentClassLogger());
        }

        private void LInfo(string msg, params object[] args)
        {
            logger.Info(msg, args);
        }

        private void LInfo(string msg, Exception err)
        {
            logger.Info(msg, err);
        }

        private void LError(string msg, params object[] args)
        {
            logger.Error(msg, args);
        }

        private void LError(string msg, Exception err)
        {
            logger.Error(msg, err);
        }

        private void LDebug(string msg, params object[] args)
        {
            logger.Debug(msg, args);
        }

        private void LDebug(string msg, Exception err)
        {
            logger.Debug(msg, err);
        }
        #endregion
    }
}
